<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <p>{{ name }}</p>
    </div>

    <template id="hello">
        <div>
            <h2> {{ name }} </h2>
            <button @click="name='bbb'">按钮</button>
        </div>
    </template>
</body>
<script>
    var vm = new Vue({
        el:'#app',
        data:{
            name:'aaa'
        },
        template:'#hello',
        beforeCreate(){
            console.log('beforeCreate', this.$data, this.$el)
        },
        created(){ // 一般在这里发送ajax请求
            console.log('created', this.$data, this.$el)
        },
        beforeMount:function(){
            console.log('beforeMount', this.$data, this.$el)
        },
        mounted(){ // 一般在这里操作dom
            console.log('mounted', this.$data, this.$el)
        },
        beforeUpdate:function(){
            console.log('beforeUpdate')
        },
        updated:function(){ // 常用
            console.log('updated')
        },
        beforeDestroy:function(){
            console.log('beforeDestroy')
        },
        destroyed:function(){
            console.log('destroyed')
        }
    })

    vm.$destroy()
</script>
</html>